可愛鯨魚誰能割捨?連 Kubernetes 也不能~
上一篇安裝好 Docker 了,今天繼續 Kubernetes 的部分~
因為 Dcoker 預設 cgroup driver 為 cgroupfs
,而 Kubernetes 預設為 systemd
,兩邊要設定一致,這邊選擇修改 Docker 為 systemd
sudo bash -c "cat > /etc/docker/daemon.json <<EOF
{
\"exec-opts\": [\"native.cgroupdriver=systemd\"]
}
EOF
"
設定完記得重啟 Docker ~
sudo systemctl restart docker
檢查有沒有配置成功
docker info | grep Cgroup
output... 應該要顯示使用
systemd
Cgroup Driver: systemd
Cgroup Version: 1
Kubernetes 已移除對 dockershim 的支援,若要繼續使用 Docker 作為 Container Runtime 需要安裝 cri-dockerd 做為介接 Kubernetes 和 Docker 的橋樑
(畢竟鯨魚這麼可愛,怎麼能完全放棄呢)
詳情:Updated: Dockershim Removal FAQ | Kubernetes
我使用的 OS 為 Ubuntu 20.04.3 (Focal) 有 release 可直接使用
其他 OS 版本 Releases · Mirantis/cri-dockerd,或是依照教學自行 Build and install - Mirantis/cri-dockerd
wget https://github.com/Mirantis/cri-dockerd/releases/download/v0.2.5/cri-dockerd_0.2.5.3-0.ubuntu-focal_amd64.deb
sudo dpkg -i cri-dockerd_0.2.5.3-0.ubuntu-focal_amd64.deb
output...
Selecting previously unselected package cri-dockerd.
(Reading database ... 72134 files and directories currently installed.)
Preparing to unpack cri-dockerd_0.2.5.3-0.ubuntu-focal_amd64.deb ...
Unpacking cri-dockerd (0.2.5~3-0~ubuntu-focal) ...
Setting up cri-dockerd (0.2.5~3-0~ubuntu-focal) ...
Created symlink /etc/systemd/system/multi-user.target.wants/cri-docker.service → /lib/systemd/system/cri-docker.service.
Created symlink /etc/systemd/system/sockets.target.wants/cri-docker.socket → /lib/systemd/system/cri-docker.socket.
測試安裝
cri-dockerd --help
reload service
sudo systemctl daemon-reload
sudo systemctl enable cri-docker.service
sudo systemctl enable --now cri-docker.socket
檢查 service 狀態
sudo systemctl status cri-docker.socket
output... 正常!
接著安裝 Kubernetes 主體~
sudo apt-get update
sudo apt-get install -y apt-transport-https
sudo curl -fsSLo /usr/share/keyrings/kubernetes-archive-keyring.gpg https://packages.cloud.google.com/apt/doc/apt-key.gpg
echo "deb [signed-by=/usr/share/keyrings/kubernetes-archive-keyring.gpg] https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kubernetes.list
我安裝的版本為 v1.25.1
sudo apt-get update
sudo apt-get install -y kubelet kubeadm kubectl
sudo apt-mark hold kubelet kubeadm kubectl
這兩天的配置 每個 node 都必須做一次
每台機器都要安裝一次阿~~已手殘 N 次...
建立 cluster 留到明天好了...
您好 :
執行了 sudo apt-get install -y kubelet kubeadm kubectl 出現如下的訊息
Reading package lists... Done
Building dependency tree
Reading state information... Done
No apt package "kubeadm", but there is a snap with that name.
Try "snap install kubeadm"
No apt package "kubectl", but there is a snap with that name.
Try "snap install kubectl"
No apt package "kubelet", but there is a snap with that name.
Try "snap install kubelet"
E: Unable to locate package kubelet
E: Unable to locate package kubeadm
E: Unable to locate package kubectl
google 了一下試著改了 /etc/apt/sources.list.d/kubernetes.list
的內容都沒找到解決的方式 , 請問錯誤訊息如何解決方式 , 辛苦您了 , 謝謝您!
可能是 apt 套件沒更新到哦
更新完檢查一下有沒有在 cache
sudo apt-get update
apt-cache madison kubeadm
# 只找最新的幾個版本
apt-cache madison kubeadm | head
果然是套件沒更新到 , 謝謝您!